<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="人脉信息更新,系统提示," />










<meta name="description" content="“对于当前用户持有的非注册用户的名片，系统根据一定规则检测有新的数据更新时提示用户。”">
<meta name="keywords" content="人脉信息更新,系统提示">
<meta property="og:type" content="article">
<meta property="og:title" content="人脉信息更新">
<meta property="og:url" content="http://yoursite.com/2016/09/27/cardUpdateNotification/index.html">
<meta property="og:site_name" content="Frone&#39;s Blog">
<meta property="og:description" content="“对于当前用户持有的非注册用户的名片，系统根据一定规则检测有新的数据更新时提示用户。”">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-07-13T11:06:08.767Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="人脉信息更新">
<meta name="twitter:description" content="“对于当前用户持有的非注册用户的名片，系统根据一定规则检测有新的数据更新时提示用户。”">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2016/09/27/cardUpdateNotification/"/>





  <title>人脉信息更新 | Frone's Blog</title><!-- hexo-inject:begin --><!-- hexo-inject:end -->
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <!-- hexo-inject:begin --><!-- hexo-inject:end --><div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Frone's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术小窝</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2016/09/27/cardUpdateNotification/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Frone Xie">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Frone's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">人脉信息更新</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-09-27T14:07:19+08:00">
                2016-09-27
              </time>
            

            

            
          </span>

          

          
            
          

          
          
             <span id="/2016/09/27/cardUpdateNotification/" class="leancloud_visitors" data-flag-title="人脉信息更新">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p><excerpt in="" index="" |="" 首页摘要=""><br>“对于当前用户持有的非注册用户的名片，系统根据一定规则检测有新的数据更新时提示用户。”<a id="more"></a></excerpt></p>
<the rest="" of="" contents="" |="" 余下全文="">

<h2 id="源码"><a href="#源码" class="headerlink" title="源码"></a>源码</h2><ul>
<li><p>版本库地址：</p>
<ul>
<li><p>OFFICE:   <code>git@192.168.30.251:cardUpdateNotification.git</code></p>
</li>
<li><p>IDC: <code>git@172.17.4.151:cardUpdateNotification.git (云主机 /data/git/ 目录下)</code></p>
</li>
</ul>
</li>
<li><p>部署位置:</p>
<p><code>BJIDC-Oradt-DMMySQL-1:/opt/workspace/cardUpdateNotification</code> (IP: <code>172.17.4.1</code>/<code>192.168.1.138</code>)</p>
</li>
</ul>
<h2 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h2><blockquote>
<p>对于当前用户持有的非注册用户的名片，系统根据一定规则检测有新的数据更新时提示用户。并推荐持有人（未来）</p>
<p>判断规则：</p>
<p>1）5个以上其他用户也持有（名片 姓名、手机号一致）</p>
<p>2）其他用户持有名片主要信息一致（姓名、手机号、公司名称、职位），但与我持有名片信息不一致（公司名称、职位有至少一项不一致）</p>
<p>3）其他用户是在我对名片的最后修改时间后  获取或更新</p>
<p>提示时间：系统定期（一天）检测，发现有不一致信息后，在每天19点（可配置），为用户 推送该消息 （实现有问题全库轮询？？）</p>
</blockquote>
<p>详见黄小明邮件(2016年9月14日13时)</p>
<h2 id="数据源及说明"><a href="#数据源及说明" class="headerlink" title="数据源及说明"></a>数据源及说明</h2><ul>
<li><p>获取名片信息</p>
<ul>
<li><p>目标数据库: <code>172.17.4.3:3306/oradt_cloud</code></p>
</li>
<li><p>数据表</p>
<ul>
<li><p><strong>contact_card</strong>: 名片状态表（来源等）</p>
</li>
<li><p><strong>contact_card_vcardinfo</strong>: 名片具体信息表</p>
</li>
<li><p><strong>account_basic</strong>: 注册用户信息表</p>
</li>
</ul>
</li>
</ul>
<p>从以上数据表中获取所要操作的名片</p>
</li>
<li><p>过滤规则</p>
<p>  <code>cellphone</code>字段：从名片信息表中获取vCard格式的<code>TEL</code>字段，使用正则表达式抽取<strong>第一个</strong>CELL作为该名片的<code>cellphone</code></p>
<ul>
<li><p>过滤已注册用户：</p>
<ul>
<li><p>从注册用户信息表中获取出已注册手机号集合</p>
</li>
<li><p>过滤掉<code>cellphone</code>在已注册手机号集合里的名片</p>
</li>
</ul>
</li>
<li><p><code>cellphone</code>不能为空</p>
<p>如果<code>cellphone</code>为空，根据<code>fn</code>和<code>cellphone</code>进行分组，就退化成<strong>仅用</strong><code>fn</code>进行分组，无法处理重名的名片。</p>
</li>
</ul>
</li>
<li><p>名片持有人</p>
<blockquote>
<p>5个以上其他用户也持有（名片 姓名、手机号一致）</p>
</blockquote>
<p>这里5个<em>其他用户</em>用5个<strong>（姓名，手机号）</strong> 组对代替，而非5个不同的<code>user_id</code>。同一用户可能拥有不同<strong>（姓名，手机号）</strong> 组对。</p>
</li>
</ul>
<h2 id="整体思路"><a href="#整体思路" class="headerlink" title="整体思路"></a>整体思路</h2><ul>
<li><p>获取数据库表中的名片信息数据，并进行过滤（过滤规则：未注册，且<code>cellphone</code>不能为空）</p>
</li>
<li><p>先使用<code>fn</code>和<code>cellphone</code>分组，得到一级分组Group_1L，每组中的名片都属于同一个人，但<code>org</code>, <code>title</code>可能不同</p>
</li>
<li><p>过滤掉一级分组Group_1L中每组数量小于预设值（<em><code>5</code>个以上其他在用户也持有</em>）的名片</p>
</li>
<li><p>在一级分组Group_1L之上，对每组再使用<code>org</code>和<code>title</code>进行分组，得到二级分组Group_2L，每组中的名片都是一张特定的名片，<code>fn</code>, <code>cellphone</code>, <code>org</code>, <code>title</code>都一样</p>
</li>
<li><p>过滤掉二级分组Group_2L中每组数量小于预设值（大于等于<code>2</code>，避免名片自身有误带来的影响）</p>
</li>
<li><p>从二级分组Group_2L中选取名片最旧的一张（即最先被录入的那张名片），加入候选集</p>
</li>
<li><p>从候选集中选出最新的一张（即该用户最新的一张名片），使用该张名片作为最后的目标名片</p>
</li>
<li><p>对一级分组Group_1L中<strong>该组</strong>（<code>fn</code>和<code>cellphone</code>相同）未拥有该张名片（<code>org</code><strong>或</strong><code>title</code>不同）的所有用户提醒更新</p>
</li>
<li><p>将提醒消息【<code>to_user</code>, <code>card_id</code>, <code>new_card_id</code>】插入数据库中</p>
</li>
</ul>
<h2 id="运行概况"><a href="#运行概况" class="headerlink" title="运行概况"></a>运行概况</h2><p>  在BJIDC-Oradt-DMMySQL-1（IDC部署环境 ）上运行该脚本，以下是运行结果：</p>
<p>  从数据库表中获取数据量：<strong>2919117</strong>，过滤后，一级分组输入数据量：<strong>1855257</strong></p>
<blockquote>
<p>Total Messages: 128549<br>python cardUpdateNotification.py  678.20s user 3.95s system 98% cpu 11:34.90 total</p>
</blockquote>
<p>  共产生<strong>128549</strong>条消息，用时<strong>11分钟35秒</strong>。</p>
<p>  <strong>注：</strong> 一次产生的消息量<code>10w</code> 级，如果每天更新，插入数据库，请考虑可行性。</p>
<p>  <em>建议： 对于消息通知结果表中，如果插入的数据相同【<code>to_user</code>, <code>card_id</code>, <code>new_card_id</code>】，则不再插入（联合主键可以确保插入相同的数据时，插入操作失败），加入一个<code>是否通知</code>列或<code>最后通知时间</code>列说明状态，但需根据业务情况考虑什么情况下更新这些状态列（每天一次？谁更新？）。</em></p>
<h2 id="补充消息推送的格式"><a href="#补充消息推送的格式" class="headerlink" title="补充消息推送的格式"></a>补充消息推送的格式</h2><h4 id="——by-mazf"><a href="#——by-mazf" class="headerlink" title="——by mazf"></a>——by mazf</h4><ul>
<li>消息json格式（参考黄小明的消息文档 push_message_list.xlsx）：<br>{“messagetype”:124,”params”:<br>{<br>“accountid”:”所属人clientid”,<br>“imid”:”11”,<br>“vcardid”:”名片id”,<br>“picture”:”名片缩略图”,<br>“contactname”: “名片姓名”<br>}<br>}</li>
<li>数据库 message_queue 表：<br>这个表中需要写入的数据有如下4个字段：<br>type, to_uid, content, created_time</li>
<li>Python 代码中 notice 函数，返回推送消息列表，循环调用 sendMsg 函数。</li>
</ul>
<p>插入数据接口已预留，但现在数据库还没有建表，具体写入位置还待确定；</p>
<h2 id="配置文件依照需求适当修改。"><a href="#配置文件依照需求适当修改。" class="headerlink" title="配置文件依照需求适当修改。"></a>配置文件依照需求适当修改。</h2><p>配置文件示例：<br>{<br>  “r”:{ # 读数据配置<br>    “host”: “192.168.1.138”,<br>    “port”: 3306,<br>    “user”: “dm_rw”,<br>    “password”: “dmrw4142”,<br>    “db”: “oradt_cloud”,<br>    “cardsQuery”: “select t1.user_id, t1.uuid, FN, TEL, ORG, TITLE, last_modified, t1.picture from contact_card t1 left join contact_card_vcardinfo t2 on t1.uuid = t2.card_id where t1.status = ‘active’ and t1.self = ‘false’ limit 100000;”,<br>    “regUsersQuery”: “select distinct mobile from account_basic;”<br>  },<br>  “w”:{ # 写数据配置<br>    “host”: “localhost”,<br>    “port”: 3306,<br>    “user”: “root”,<br>    “password”: “mazf”,<br>    “db”: “test”<br>  }<br>}</p>
<hr>
</the>
      
    </div>
    
    
    

    
      <div>
        <div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="/uploads/wechat-qcode.jpg" alt="Frone Xie wechat" style="width: 200px; max-width: 100%;"/>
    <div>欢迎关注我的微信公众号！</div>
</div>

      </div>
    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/人脉信息更新/" rel="tag"># 人脉信息更新</a>
          
            <a href="/tags/系统提示/" rel="tag"># 系统提示</a>
          
        </div>
      

      
      
        <div class="post-widgets">
        

        

        
          
          <div id="needsharebutton-postbottom">
            <span class="btn">
              <i class="fa fa-share-alt" aria-hidden="true"></i>
            </span>
          </div>
        
        </div>
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/09/26/clouderaCluster/" rel="next" title="cloudera集群环境说明文档">
                <i class="fa fa-chevron-left"></i> cloudera集群环境说明文档
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/09/30/cardRectify/" rel="prev" title="名片纠正服务文档">
                名片纠正服务文档 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Frone Xie</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">29</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">10</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">45</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/frone" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://blog.csdn.net/frone" target="_blank" title="CSDN">
                      
                        <i class="fa fa-fw fa-CSDN"></i>CSDN</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#源码"><span class="nav-number">1.</span> <span class="nav-text">源码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#背景"><span class="nav-number">2.</span> <span class="nav-text">背景</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#数据源及说明"><span class="nav-number">3.</span> <span class="nav-text">数据源及说明</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#整体思路"><span class="nav-number">4.</span> <span class="nav-text">整体思路</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#运行概况"><span class="nav-number">5.</span> <span class="nav-text">运行概况</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#补充消息推送的格式"><span class="nav-number">6.</span> <span class="nav-text">补充消息推送的格式</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#——by-mazf"><span class="nav-number">6.0.1.</span> <span class="nav-text">——by mazf</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置文件依照需求适当修改。"><span class="nav-number">7.</span> <span class="nav-text">配置文件依照需求适当修改。</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Frone Xie</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user">本站访客数</i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人数
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye">本站总访问量</i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>





  <script type="text/javascript">
    (function() {
      var hm = document.createElement("script");
      hm.src = "//tajs.qq.com/stats?sId=65946112";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
      <div id="needsharebutton-float">
        <span class="btn">
          <i class="fa fa-share-alt" aria-hidden="true"></i>
        </span>
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("ohqkXUU5txOlX3MjJPCrw7jG-gzGzoHsz", "bPQhLzRSEsTqdIKAGRcHLhyN");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  
  
  <link rel="stylesheet" href="/lib/needsharebutton/needsharebutton.css">

  
  
  <script src="/lib/needsharebutton/needsharebutton.js"></script>

  <script>
    
      pbOptions = {};
      
          pbOptions.iconStyle = "box";
      
          pbOptions.boxForm = "horizontal";
      
          pbOptions.position = "bottomCenter";
      
          pbOptions.networks = "Weibo,Wechat,Douban,QQZone,Twitter,Facebook";
      
      new needShareButton('#needsharebutton-postbottom', pbOptions);
    
    
      flOptions = {};
      
          flOptions.iconStyle = "box";
      
          flOptions.boxForm = "horizontal";
      
          flOptions.position = "middleRight";
      
          flOptions.networks = "Weibo,Wechat,Douban,QQZone,Twitter,Facebook";
      
      new needShareButton('#needsharebutton-float', flOptions);
    
  </script>

  

  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


  

  

  <script type="text/javascript" src="/js/src/love.js"></script><!-- hexo-inject:begin --><!-- hexo-inject:end -->
</body>
</html>
